<?php
namespace app\admin\controller;

use app\admin\controller\Base;
use app\admin\model\Menu;
use app\admin\model\User;

class Index extends Base
{
    /*
     * 后台首页
     */
    public function index()
    {
        $user = $this->user_info();
        $menu = Menu::where(array("pid"=>0,"id"=>array("in",$user['jurisdiction'])))->order("sort asc")->select();
        $menu = collection($menu)->toArray();
        foreach($menu as $key=>$val){
            $menuTow = Menu::where(array('pid'=>$val['id'],"id"=>array("in",$user['jurisdiction'])))->order("sort asc")->select();
            $menu[$key]['menuTow'] = collection($menuTow)->toArray();
        }
        //查询user表中一共有几级学生
        $grade = User::field("grade")->group("grade")->order("grade desc")->select(); //用于导航列表
        $data = array(
            "setting" => $this->getAllSetting(),
            "list" =>$menu,
            "grade" => $grade
        );
        return view('index',$data);
    }
}
